<?
require_once("../config/dbconn.php");require_once("../config/usercls.php");require_once("pwd1cls.php");

$sqlhy="select * from {$db_prefix}users where id='".$_SESSION['sys_userid']."'";
$rshy=$db->get_one($sqlhy);

if($act=='transdo'){
	$msg='';
	if(floatval($price)<=0) $msg.="请输入转账金额\\n";
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	if ($rshy['gpprice']<floatval($price)) $msg.="您没有足够的股票余额\\n";
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	$feiyong=0;
	$feiyong=floatval($price)*$glo_jjtransrate/100;
	$realprice=floatval($price)-$feiyong;
	
	//扣款。提现
	$sqlkk="update {$db_prefix}users set gpprice=gpprice-'".floatval($price)."',price=price+'".$realprice."' where id='".$_SESSION['sys_userid']."'";
	$db->query($sqlkk);
	//财务记录
	$e_userid=$_SESSION['sys_userid'];$e_price=-floatval($price);$e_type=4;$e_ptype=4;$e_addtime=$curtime;$e_memo="股票转出报单币";
	hyepricejl($e_userid,$e_price,$e_type,$e_ptype,$e_addtime,$e_memo);
	$e_userid=$_SESSION['sys_userid'];$e_price=$realprice;$e_type=6;$e_ptype=1;$e_addtime=$curtime;$e_memo="股票转出报单币";
	hyepricejl($e_userid,$e_price,$e_type,$e_ptype,$e_addtime,$e_memo);
	
	//插入数据库
	$dataArray['username']=$_SESSION['sys_username'];
	$dataArray['price']=floatval($price);
	$dataArray['feiyong']=$feiyong;
	$dataArray['memo']=addslashes($memo);
	$dataArray['toptype']=1;
	$dataArray['addtime']=$curtime;
	$db->insert("{$db_prefix}transfer",$dataArray);
	echo "<script>alert('股票转账报单币成功');location.href='trans_bd.php';</script>";exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	
}
.red{
	color:#FF0000
}

-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td width="935" height="29" valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">
          <p >股票转报单币</p>
          </div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top">
		<form id="form1" name="form1" method="post" action="?act=transdo">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="3"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;您的股票余额：
                    <?=$rshy['gpprice']?>美金</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30" colspan="3">
			  
			  <table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td height="30" align="center" class="left_txt">金额</td>
                  <td height="30" class="left_txt"><label>
                    <input name="price" type="text" id="price" size="10" value="">
                    美金
                    <span class="red">* <? if ($glo_jjtransrate>0) {?>股票转账手续费：<?=$glo_jjtransrate?>%<? }?></span></label></td>
                </tr>
				   <tr>
                  <td height="30" align="center" class="left_txt">说明</td>
                  <td height="30" class="left_txt"><label>
                    <textarea name="memo" cols="40" rows="6" id="memo"><?=stripslashes($rs['memo'])?></textarea>
                  </label></td>
                </tr>
              </table></td>
            </tr>
            
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
            <tr>
              <td width="50%" height="30" align="right">
<input type="submit" value="完成以上修改" name="B1" /></td>
              <td width="6%" height="30" align="right">&nbsp;</td>
              <td width="44%" height="30"><input type="reset" value="取消设置" name="B12" /></td>
            </tr>
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
          </table>
		  </form>
		  </td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>

</body>
</html>